﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using OpenLab.BLL;
using OpenLab.Model;
namespace OpenLab.UI.Shared
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (logintxt.Text == "" || passwordtxt.Text == "") return;
                

            var securepassword = Helper.Encryptor.MD5Hash(passwordtxt.Text);

            var utilisateur = new UtilisateurBLL().GetLoginUser(new Utilisateur() { login = logintxt.Text, password = securepassword });

            if (utilisateur!=null)
            {
                Helper.StaticVar.LogedIn = true;
                Helper.StaticVar.CurrentUser = utilisateur;
            }
            Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
